<%@page import="dao.Prelevance"%>
<%@page import="beans.Prelevancebean"%>
<%@page import="beans.KnowledgePointbean"%>
<%@page import="dao.Course"%>
<%@page import="util.Utilities"%>
<%@page import="dao.Knowledgepoint"%>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
    String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%!String getType(String typeString) {
	if ("normal".equals(typeString)) {
	    return "普通知识点";
	} else if ("difficult".equals(typeString)) {
	    return "难点";
	} else if ("important".equals(typeString)) {
	    return "重点";
	}else{
	    return "";
	}
    }%>
<%
    String chapterid = null;
	List<Knowledgepoint> list = null;
	KnowledgePointbean knowledgePointbean = null; 
	int[] knowledgeIds = null;
	if(request.getQueryString() !=null){
    knowledgePointbean = new KnowledgePointbean(); 
    chapterid = request.getParameter("chapterid").trim();
    list = knowledgePointbean.getChapterKnowledgepoints(chapterid);
    knowledgeIds = new int[list.size()];
    for(int x=0;x<list.size();x++){
		knowledgeIds[x] = list.get(x).getKnowledgeid();
    }
}
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>章节知识点</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
<style type="text/css">
body {
	font: normal 15px auto "Trebuchet MS", Verdana, Arial, Helvetica,
		sans-serif;
	color: #4f6b72;
	text-align: left;
	background: #E6EAE9;
}

#container {
	margin-left: auto;
	margin-right: auto;
	width: 1280px;
	height: 800px;
	background: #f8f8f8;
	display: block;
	vertical-align: middle;
}

.ele {
	margin-top: 30px;
	text-align: left;
	width: 100%;
	display: block;
	vertical-align: middle;
}
</style>
</head>
<body>
	<div id="container">
	<a id="top1" name="top1"></a>
		<c:choose>
			<c:when test="<%=list==null %>">
				<c:out value="参数有误，没有相应知识点"></c:out>
			</c:when>
			<c:otherwise>				
				<%
				    for (Knowledgepoint knowledgepoint : list) {
				%>
				<a id="<%=knowledgepoint.getKnowledgeid()%>"></a>
				<div class="ele">
					<h5><%=knowledgepoint.getTitle()%></h5>
					<span>知识点类型：<%=getType(knowledgepoint.getKnowledgetype())%></span><br>
					<label>知识点介绍：</label><br> <span><%=knowledgepoint.getDescription()%></span><br>
					<label>例题：</label><br> <c:if test="<%=knowledgepoint.getExample() !=null %>">
						<c:out value="<%=knowledgepoint.getExample() %>"></c:out>
						<br>
					</c:if>
					<c:if test="<%=knowledgepoint.getPath() !=null %>">
						<img alt="实例" src=".<%=knowledgepoint.getPath()%>">
					</c:if>
					<c:if test="<%=knowledgepoint.getPath() ==null && knowledgepoint.getExample() ==null %>">
						<c:out value="略"></c:out>
					</c:if><br>
 	<label>相关知识点：</label>
 	<%
 		List<Knowledgepoint> prelevanceKnowledges = knowledgePointbean.getPrelevanceKnowledges(knowledgepoint.getKnowledgeid());
 		for(int i=0;i<prelevanceKnowledges.size();i++){
 		    int id = prelevanceKnowledges.get(i).getKnowledgeid();
 		    int n=0;
 		for(;n<knowledgeIds.length;n++){
 		   if(id == knowledgeIds[n]){
 		       %>
 		       <a href="javascript:void(0)" onclick="document.getElementById('<%=id%>').scrollIntoView();"><%=prelevanceKnowledges.get(i).getTitle() %></a>&nbsp;&nbsp;&nbsp;&nbsp;
 		       <% 
 		       break;
 		   }
 		}
 		if(n >=knowledgeIds.length){
 		    %>
 		    <a href="./common/knowledgePoint.jsp?knowledgeid=<%=id %>"><%=prelevanceKnowledges.get(i).getTitle() %></a>
 			<%
 		}
 		}
 	%>
 	<hr>
 	</div>
					<%
					    }
					%>
					
			</c:otherwise>
		</c:choose>
	<a href="javascript:void(0)" onclick="document.getElementById('top1').scrollIntoView();">回到顶部</a>	
	</div>
</body>
</html>
